<?php

error_reporting(E_ALL);

/**
 * ECommerce - class.Modelo.php
 *
 * $Id$
 *
 * This file is part of ECommerce.
 *
 * Automatically generated on 17.11.2011, 10:36:12 with ArgoUML PHP module 
 * (last revised $Date: 2010-01-12 20:14:42 +0100 (Tue, 12 Jan 2010) $)
 *
 * @author firstname and lastname of author, <author@example.org>
 */

if (0 > version_compare(PHP_VERSION, '5')) {
    die('This file was generated for PHP 5');
}

/* user defined includes */
// section 127-0-0-1--2bc61e:12e6b7c56db:-8000:0000000000000E2D-includes begin
require_once('class.Conexion.php');
// section 127-0-0-1--2bc61e:12e6b7c56db:-8000:0000000000000E2D-includes end

/* user defined constants */
// section 127-0-0-1--2bc61e:12e6b7c56db:-8000:0000000000000E2D-constants begin
// section 127-0-0-1--2bc61e:12e6b7c56db:-8000:0000000000000E2D-constants end

/**
 * Short description of class Modelo
 *
 * @access public
 * @author firstname and lastname of author, <author@example.org>
 */
class Modelo
extends Conexion
{
	
    // --- ASSOCIATIONS ---


    // --- ATTRIBUTES ---

    // --- OPERATIONS ---

    /**
     * Short description of method getAllRows
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @return mixed
     */
    public function getAllRows()
    {
        // section 127-0-0-1--2bc61e:12e6b7c56db:-8000:0000000000000E38 begin
		$sql = "SELECT * FROM productos";
		return $this->ejecutarQuery($sql);
        // section 127-0-0-1--2bc61e:12e6b7c56db:-8000:0000000000000E38 end
    }
   
    /**
     * Short description of method searchById
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @param  id
     * @return mixed
     */
    public function searchById($id)
    {
        // section 127-0-0-1--2bc61e:12e6b7c56db:-8000:0000000000000E3A begin
		$sql = "SELECT * FROM productos WHERE id = '$id'";
		$row0 = $this->ejecutarQuery($sql);
		return $row0[0];
        // section 127-0-0-1--2bc61e:12e6b7c56db:-8000:0000000000000E3A end
    }

    /**
     * Short description of method insertRow
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @param  datos
     * @return mixed
     */
    public function insertRow($datos)
    {
        // section 127-0-0-1--2bc61e:12e6b7c56db:-8000:0000000000000E3C begin
		$desc = @$datos['desc'];
		$precio = @$datos['precio'];
		$foto = @$datos['foto'];
		$proveedor = @$datos['proveedor'];
		$sql = "INSERT INTO productos (descripcion,precio,foto,proveedor) VALUES ('$desc',$precio,'imagenes/$foto','$proveedor')";
		$this->ejecutarQuery($sql);	
		return mysql_insert_id();
        // section 127-0-0-1--2bc61e:12e6b7c56db:-8000:0000000000000E3C end
    }

    /**
     * Short description of method updateRow
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @param  datos
     * @return mixed
     */
    public function updateRow($datos)
    {
        // section 127-0-0-1--2bc61e:12e6b7c56db:-8000:0000000000000E3E begin
		$sql= "
			UPDATE productos SET 
				descripcion = '".@$datos[descripcion]."',
				precio = '".@$datos[precio]."',
				foto = 'imagenes/".@$datos[foto]."',
				proveedor = '".@$datos[proveedor]."'
				WHERE id = '".@$datos[id]."'
		";
		$this->ejecutarQuery($sql);
        // section 127-0-0-1--2bc61e:12e6b7c56db:-8000:0000000000000E3E end
    }

    /**
     * Short description of method deleteRow
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @param  id
     * @return mixed
     */
    public function deleteRow($id)
    {
        // section 127-0-0-1--2bc61e:12e6b7c56db:-8000:0000000000000E40 begin
		$sql= "DELETE FROM productos WHERE id = $id";
		$this->ejecutarQuery($sql);
        // section 127-0-0-1--2bc61e:12e6b7c56db:-8000:0000000000000E40 end
    }

    /**
     * Short description of method getRowsByDescripcion
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @param  Descripcion
     * @return mixed
     */
    public function getRowsByDescripcion($Descripcion)
    {
        // section -64--88-0-101-394c2aa1:1330321bd70:-8000:0000000000000D01 begin
		$sql = "SELECT * FROM productos WHERE descripcion LIKE '%".$Descripcion."%'";
		return $this->ejecutarQuery($sql);
        // section -64--88-0-101-394c2aa1:1330321bd70:-8000:0000000000000D01 end
    }

} /* end of class Modelo */

?>